package com.remon.quartz.controller;

import com.remon.quartz.entity.QrtzCronTriggers;
import com.remon.quartz.service.QrtzCronTriggersService;
import com.remon.quartz.vo.PageRes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 触发器表达式controller
 *
 * @author remon
 * @create 2018-09-09 0:02
 **/
@RestController
@RequestMapping("qrtzCronTrigger")
public class QrtzCronTriggersController {

    /**
     * 获取触发器表达式逻辑处理对象
     */
    private final QrtzCronTriggersService qrtzCronTriggersService;

    @Autowired
    public QrtzCronTriggersController(QrtzCronTriggersService qrtzCronTriggersService) {
        this.qrtzCronTriggersService = qrtzCronTriggersService;
    }

    /**
     * 分页获取触发器表达式
     *
     * @param pageNo   跳转页
     * @param pageSize 每页大小
     * @return @link{ PageRes } @link{ QrtzCronTriggers }
     */
    @GetMapping("page/{pageNo}/{pageSize}")
    public PageRes<QrtzCronTriggers> page(@PathVariable("pageNo") Integer pageNo, @PathVariable("pageSize") Integer pageSize) {
        return qrtzCronTriggersService.pages(pageNo, pageSize, null);
    }
}
